package dao;


import model.MakeupNotice;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class MakeupNoticeCanvasDao {
    private MakeupNoticeCanvasDao() {

    }

    public static List<MakeupNotice> getMakeupNotices() throws SQLException {
        List<MakeupNotice> list = new ArrayList<>();

        String sql = "select student.s_no,student.s_name,score.c_name " +
                "from student,score " +
                "where student.s_no=score.s_no and score.final_score<60";

        PreparedStatement stmt = Dao.getConnection().prepareStatement(sql);
        ResultSet rs = stmt.executeQuery();

        while (rs.next()) {
            String sno = rs.getString(rs.findColumn("s_no"));
            String sname = rs.getString(rs.findColumn("s_name"));
            String cname = rs.getString(rs.findColumn("c_name"));

            MakeupNotice makeupNotice = new MakeupNotice();
            makeupNotice.setSno(sno);
            makeupNotice.setSname(sname);
            makeupNotice.setCname(cname);
            list.add(makeupNotice);
        }

        return list;
    }
}
